package org.pentaho.actioneditor.client.actionpanels;

import com.google.gwt.user.client.ui.*;
import org.pentaho.actioneditor.client.messages.Messages;
import org.pentaho.actioneditor.client.util.ActionParameterMenu;


public class SqlQueryActionUI {

  private FlexTable root = new FlexTable();
  private TextBox name = new TextBox();
  private RadioButton jdbcRadio = new RadioButton("connectionType", Messages.getUIInstance().sqlqueryactionui_Jdbc());
  private RadioButton jndiRadio = new RadioButton("connectionType", Messages.getUIInstance().sqlqueryactionui_Jndi());
  private RadioButton sharedRadio = new RadioButton("connectionType", Messages.getUIInstance().sqlqueryactionui_Shared());
  private RadioButton liveRadio = new RadioButton("resultSetType", Messages.getUIInstance().sqlqueryactionui_LiveResultSet());
  private RadioButton memoryRadio = new RadioButton("resultSetType", Messages.getUIInstance().sqlqueryactionui_InmemoryResultSet());
  private DeckPanel connectionTypeDock = new DeckPanel();
  private TextBox jdbcDriver = new TextBox();
  private ActionParameterMenu jdbcDriverActionInputMenu = new ActionParameterMenu();
  private TextBox username = new TextBox();
  private ActionParameterMenu usernameActionInputMenu = new ActionParameterMenu();
  private TextBox databaseUrl = new TextBox();
  private ActionParameterMenu databaseUrlActionInputMenu = new ActionParameterMenu();
  private TextBox password = new TextBox();
  private ActionParameterMenu passwordActionInputMenu = new ActionParameterMenu();
  private TextBox jndiName = new TextBox();
  private ActionParameterMenu jndiNameActionInputMenu = new ActionParameterMenu();
  private TextBox sharedName = new TextBox();
  private ActionParameterMenu sharedNameActionInputMenu = new ActionParameterMenu();
  private TextArea query = new TextArea();
  private RadioButton immediateRadio = new RadioButton("runQuery", Messages.getUIInstance().sqlqueryactionui_RunQueryImmediately());
  private RadioButton subreportRadio = new RadioButton("runQuery", Messages.getUIInstance().sqlqueryactionui_RunQueryFromPentahoSubreport());
  private DeckPanel resultSetDeck = new DeckPanel();
  private TextBox resultSetName = new TextBox();
  private FlexTable resultSetColumns = new FlexTable();
  private TextBox subqueryName = new TextBox();


  public void init() {
    Label obj62 = new Label(Messages.getUIInstance().sqlqueryactionui_Name());
    root.setWidget(0,0,obj62);
    root.getFlexCellFormatter().setColSpan(0,0,2);
    root.setWidget(1,0,name);
    root.getFlexCellFormatter().setColSpan(1,0,2);
    Label obj63 = new Label(Messages.getUIInstance().sqlqueryactionui_DatabaseConnectionType());
    root.setWidget(2,0,obj63);
    root.getColumnFormatter().setWidth(0, "50%");
    Label obj64 = new Label(Messages.getUIInstance().sqlqueryactionui_ResultSetType());
    root.setWidget(2,1,obj64);
    root.getColumnFormatter().setWidth(1, "50%");
    HorizontalPanel obj65 = new HorizontalPanel();
    obj65.add(jdbcRadio);
    obj65.add(jndiRadio);
    obj65.add(sharedRadio);
    root.setWidget(3,0,obj65);
    root.getColumnFormatter().setWidth(0, "50%");
    HorizontalPanel obj66 = new HorizontalPanel();
    obj66.add(liveRadio);
    obj66.add(memoryRadio);
    root.setWidget(3,1,obj66);
    root.getColumnFormatter().setWidth(1, "50%");
    HorizontalPanel obj67 = new HorizontalPanel();
    VerticalPanel obj68 = new VerticalPanel();
    Label obj69 = new Label(Messages.getUIInstance().sqlqueryactionui_JdbcDriver());
    obj68.add(obj69);
    HorizontalPanel obj70 = new HorizontalPanel();
    obj70.add(jdbcDriver);
    obj70.add(jdbcDriverActionInputMenu);
    obj68.add(obj70);
    Label obj71 = new Label(Messages.getUIInstance().sqlqueryactionui_UserName());
    obj68.add(obj71);
    HorizontalPanel obj72 = new HorizontalPanel();
    obj72.add(username);
    obj72.add(usernameActionInputMenu);
    obj68.add(obj72);
    obj68.setWidth("50%");
    obj67.add(obj68);
    VerticalPanel obj73 = new VerticalPanel();
    Label obj74 = new Label(Messages.getUIInstance().sqlqueryactionui_DatabaseUrl());
    obj73.add(obj74);
    HorizontalPanel obj75 = new HorizontalPanel();
    obj75.add(databaseUrl);
    obj75.add(databaseUrlActionInputMenu);
    obj73.add(obj75);
    Label obj76 = new Label(Messages.getUIInstance().sqlqueryactionui_Password());
    obj73.add(obj76);
    HorizontalPanel obj77 = new HorizontalPanel();
    obj77.add(password);
    obj77.add(passwordActionInputMenu);
    obj73.add(obj77);
    obj73.setWidth("50%");
    obj67.add(obj73);
    obj67.setWidth("100%");
    connectionTypeDock.add(obj67);
    HorizontalPanel obj78 = new HorizontalPanel();
    Label obj79 = new Label(Messages.getUIInstance().sqlqueryactionui_Name());
    obj78.add(obj79);
    obj78.add(jndiName);
    obj78.add(jndiNameActionInputMenu);
    obj78.setWidth("100%");
    connectionTypeDock.add(obj78);
    HorizontalPanel obj80 = new HorizontalPanel();
    Label obj81 = new Label(Messages.getUIInstance().sqlqueryactionui_Name());
    obj80.add(obj81);
    obj80.add(sharedName);
    obj80.add(sharedNameActionInputMenu);
    obj80.setWidth("100%");
    connectionTypeDock.add(obj80);
    connectionTypeDock.showWidget(0);
    connectionTypeDock.setWidth("100%");
    root.setWidget(4,0,connectionTypeDock);
    root.getFlexCellFormatter().setColSpan(4,0,2);
    Label obj82 = new Label(Messages.getUIInstance().sqlqueryactionui_Query());
    root.setWidget(5,0,obj82);
    root.getFlexCellFormatter().setColSpan(5,0,2);
    query.setWidth("100%");
    root.setWidget(6,0,query);
    root.getFlexCellFormatter().setColSpan(6,0,2);
    VerticalPanel obj83 = new VerticalPanel();
    obj83.add(immediateRadio);
    obj83.add(subreportRadio);
    obj83.setWidth("100%");
    root.setWidget(7,0,obj83);
    root.getColumnFormatter().setWidth(0, "50%");
    root.getFlexCellFormatter().setVerticalAlignment(7,0,HasVerticalAlignment.ALIGN_TOP);
    VerticalPanel obj84 = new VerticalPanel();
    Label obj85 = new Label(Messages.getUIInstance().sqlqueryactionui_ResultSetName());
    obj84.add(obj85);
    obj84.add(resultSetName);
    Label obj86 = new Label(Messages.getUIInstance().sqlqueryactionui_ResultSetColumns());
    obj84.add(obj86);
    obj84.add(resultSetColumns);
    obj84.setWidth("100%");
    resultSetDeck.add(obj84);
    VerticalPanel obj87 = new VerticalPanel();
    Label obj88 = new Label(Messages.getUIInstance().sqlqueryactionui_SubqueryName());
    obj87.add(obj88);
    obj87.add(subqueryName);
    obj87.setWidth("100%");
    resultSetDeck.add(obj87);
    resultSetDeck.showWidget(0);
    root.setWidget(7,1,resultSetDeck);
    root.getColumnFormatter().setWidth(1, "50%");
    root.getFlexCellFormatter().setVerticalAlignment(7,1,HasVerticalAlignment.ALIGN_TOP);
    root.setWidth("100%");

  }

  public FlexTable getRoot() {
    return root;
  }
  public TextBox getName() {
    return name;
  }
  public RadioButton getJdbcRadio() {
    return jdbcRadio;
  }
  public RadioButton getJndiRadio() {
    return jndiRadio;
  }
  public RadioButton getSharedRadio() {
    return sharedRadio;
  }
  public RadioButton getLiveRadio() {
    return liveRadio;
  }
  public RadioButton getMemoryRadio() {
    return memoryRadio;
  }
  public DeckPanel getConnectionTypeDock() {
    return connectionTypeDock;
  }
  public TextBox getJdbcDriver() {
    return jdbcDriver;
  }
  public ActionParameterMenu getJdbcDriverActionInputMenu() {
    return jdbcDriverActionInputMenu;
  }
  public TextBox getUsername() {
    return username;
  }
  public ActionParameterMenu getUsernameActionInputMenu() {
    return usernameActionInputMenu;
  }
  public TextBox getDatabaseUrl() {
    return databaseUrl;
  }
  public ActionParameterMenu getDatabaseUrlActionInputMenu() {
    return databaseUrlActionInputMenu;
  }
  public TextBox getPassword() {
    return password;
  }
  public ActionParameterMenu getPasswordActionInputMenu() {
    return passwordActionInputMenu;
  }
  public TextBox getJndiName() {
    return jndiName;
  }
  public ActionParameterMenu getJndiNameActionInputMenu() {
    return jndiNameActionInputMenu;
  }
  public TextBox getSharedName() {
    return sharedName;
  }
  public ActionParameterMenu getSharedNameActionInputMenu() {
    return sharedNameActionInputMenu;
  }
  public TextArea getQuery() {
    return query;
  }
  public RadioButton getImmediateRadio() {
    return immediateRadio;
  }
  public RadioButton getSubreportRadio() {
    return subreportRadio;
  }
  public DeckPanel getResultSetDeck() {
    return resultSetDeck;
  }
  public TextBox getResultSetName() {
    return resultSetName;
  }
  public FlexTable getResultSetColumns() {
    return resultSetColumns;
  }
  public TextBox getSubqueryName() {
    return subqueryName;
  }

}
